//
//  UIBarButtonItem+XXJBarButtonItem.m
//  不得姐
//
//  Created by 许小军 on 16/9/2.
//  Copyright © 2016年 wyzc. All rights reserved.
//

#import "UIBarButtonItem+XXJBarButtonItem.h"

@implementation UIBarButtonItem (XXJBarButtonItem)


+(UIBarButtonItem *)setNormalImage:(UIImage *)Nimage SelectedImage:(UIImage *)Simage addTarget:(id)target action:(SEL)action
{
    UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:Nimage forState:UIControlStateNormal];
    [btn setImage:Simage forState:UIControlStateHighlighted];
    [btn sizeToFit];
    
    UIView * view=[[UIView alloc]initWithFrame:btn.bounds];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    [view addSubview:btn];
    
    UIBarButtonItem * barItem=[[UIBarButtonItem alloc]initWithCustomView:view];
    return barItem;
}

+(UIBarButtonItem *)setNormalImage:(UIImage *)Nimage SSSelectedImage:(UIImage *)Simage addTarget:(id)target action:(SEL)action
{
    UIButton * btn=[UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:Nimage forState:UIControlStateNormal];
    [btn setImage:Simage forState:UIControlStateSelected];
    [btn sizeToFit];
    
    UIView * view=[[UIView alloc]initWithFrame:btn.bounds];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    [view addSubview:btn];
    
    UIBarButtonItem * barItem=[[UIBarButtonItem alloc]initWithCustomView:view];
    return barItem;
}









@end
